# encoding: utf-8
namespace :my do
  desc "reset password to 'admin'"
  task :resetpswd =>:environment do
    Mconfig.find_by_cname("password").destroy unless  Mconfig.find_by_cname("password").nil?
    puts "reset password succeed!" if Mconfig.new({:cname=>"password", :cvalue=>Digest::MD5.hexdigest("admin")}).save
  end

  desc "reset sgroup"
  task :resetgroup =>:environment do
    require 'yaml'
    Mconfig.find_by_cname("groups").destroy unless  Mconfig.find_by_cname("groups").nil?
    puts "reset sgroup succeed!" if Mconfig.new({:cname=>"groups", :cvalue=>YAML.dump(%w{金融经济 财务会计 工程管理 信息技术 法律})}).save
  end
end